package com.losdun.aftersales.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.losdun.aftersales.enums.WorkStatusEnum;
import com.losdun.common.annotation.Excel;
import com.losdun.common.core.domain.entity.SysUser;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.List;

/**
 * 售后维保对象 aftersales_repair
 * 
 * @author swordye
 * @date 2025-08-19
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@TableName("aftersales_repair")
public class Repair
{
    private static final long serialVersionUID = 1L;

    /**  */
    @TableId(type = IdType.AUTO)
    private Long id;

    /** 订单ID */
    @Excel(name = "订单ID")
    private Long orderId;

    /**  */
    private String openId;
    /** 工单编号 */
    private String workNo;

    /**
     * 维保类型
     * 3:预约保养 4:预约售后
     */
    private Integer type;

    /** 产品型号 */
    @Excel(name = "产品型号")
    private String productModel;

    /** 地址 */
    @Excel(name = "地址")
    private String address;

    /** 问题描述 */
    @Excel(name = "问题描述")
    private String problem;

    /** 问题图片 */
    @Excel(name = "问题图片")
    private String images;

    /** 视频路径 */
    @Excel(name = "视频路径")
    private String video;

    /** 联系人 */
    @Excel(name = "联系人")
    private String contacts;

    /** 联系电话 */
    @Excel(name = "联系电话")
    private String contactNumber;

    /** 派遣师傅时间 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "派遣师傅时间", width = 30, dateFormat = "yyyy-MM-dd")
    private Date conductTime;

    /** 师傅信息 */
    @Excel(name = "师傅信息")
    private String remarks;

    /** 维修完成时间 */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Excel(name = "维修完成时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    private Date finishTime;

    /** 维修完成码 */
    private String finishCode;

    /** 工单状态 */
    @Excel(name = "工单状态")
    private Integer status;

    /** 评论状态 */
    @Excel(name = "评论状态")
    private Integer commentStatus;

    /** 师傅ID */
    private Long workerId;
    /** 师傅OPENID */
    @Excel(name = "师傅OPENID")
    private String workerOpenId;

    /** 创建时间 */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;


    /** 更新时间 */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date updateTime;

    private Integer isDelay;

    /** 维保师傅 */
    @TableField(exist = false)
    private SysUser worker;
    /**
     * 订单编号
     */
    @TableField(exist = false)
    private String orderNo;

    public String getStatusLabel() {
        return WorkStatusEnum.getLabel(status);
    }

    public List<String> imagesList() {
        if(images==null){
            return Collections.emptyList();
        }
        return Arrays.asList(images.split(","));
    }

}
